home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / clchat413.lha / CLChat413 / ChatBot / source / sendchatbot.c < prev    next >
C/C++ Source or Header  |  1995-10-25  |  1KB  |  52 lines

  1. #include <proto/exec.h>
  2. #include <proto/dos.h>
  3. #include <string.h>
  4.  
  5. #include "rev.h"
  6.  
  7. struct DosLibrary *DOSBase;
  8.  
  9. char version[]á= { "$VER: SendChatBot " VERTAG };
  10.  
  11. void __saveds __entry( void )
  12. {
  13.     struct RDArgs *rda;
  14.     struct args {
  15.         char *botid;
  16.         char *txt;
  17.     } args;
  18.  
  19.     DOSBase = OldOpenLibrary( "dos.library" );
  20.  
  21.     rda = ReadArgs( "BOTID/A,TEXT/A/F", &args, NULL );
  22.     if( rda )
  23.     {
  24.         struct ipcmsg {
  25.             struct Message m;
  26.             char data[á256 ];
  27.         } im;
  28.         char servername[á128 ];
  29.         struct MsgPort *sp;
  30.  
  31.         strcpy( servername, "CHATBOT_" );
  32.         strcat( servername, args.botid );
  33.         strupr( servername );
  34.  
  35.         if( sp = FindPort( servername ) )
  36.         {
  37.             strcpy( im.data, args.txt );
  38.             im.m.mn_ReplyPort = CreateMsgPort();
  39.             PutMsg( sp, &im );
  40.             WaitPort( im.m.mn_ReplyPort );
  41.             GetMsg( im.m.mn_ReplyPort );
  42.             DeleteMsgPort( im.m.mn_ReplyPort );
  43.         }
  44.         else
  45.             Printf( "SendChatBot: No Bot with ID \"%s\" found!\n", args.botid );
  46.         FreeArgs( rda );
  47.     }
  48.     else
  49.         PrintFault( IoErr(), "SendChatBot" );
  50.     CloseLibrary( DOSBase );
  51. }
  52.